package com.hhu.userservice.controller;

import com.hhu.userservice.object.params.LoginParam;
import com.hhu.userservice.service.UserService;
import com.hhu.commonutils.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * create by: yaodao
 * description: 用户信息接口
 * create time: 2022/3/8 11:06 上午
 */

@RestController
@RequestMapping("/user")
public class UserController {
    private UserService userService;

    @Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    @GetMapping("/test")
    @CrossOrigin(origins = "*")
    public Result getUserInfo() {
        return Result.ok().Message("userService：我是王二锤！").Data("userService：我是王二锤！");
    }


    @PostMapping("/login")
    @ResponseBody
    @CrossOrigin(origins = "*")
    public Result login(@RequestBody @Valid LoginParam param) {
        return userService.login(param.getUserName(), param.getPasswordMD5());
    }
}
